Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Scripting Additions Guide /
Chapter 2 - Scripting Addition Commands / Command Definitions
/


Offset

The Offset command returns the offset of a string within a string. For example, the offset of "freedom now" contained in "Yes, freedom now" is 6, because the contained string begins with the sixth character of the container. The offset of "Yes" in the string "Yes, freedom now" is 1, because it begins with the first character of the container string. The Offset command is case-sensitive.

Offset is one of several commands provided by the String Commands
scripting addition.

SYNTAX
offset of stringToFind in stringToSearch
PARAMETERS
stringToFind

The string to find in stringToSearch.
Class: String

stringToSearch
A string containing stringToFind.
Class: String
RESULT
The result is an integer that indicates the offset, in number of characters, of
the first character of stringToFind from the beginning of stringToSearch. If stringToFind is not contained within stringToSearch, AppleScript returns the value 0.

EXAMPLES
offset of "yours" in "yours, mine, and ours"--result: 1

offset of "mine" in "yours, mine, and ours"--result: 8

offset of "this" in "yours, mine, and ours"--result: 0

offset of "Mine" in "yours, mine, and ours"--result: 0, due to case sensitivity

NOTES
The Offset command compares strings character by character, as the Equals operator does, except that the Offset command is always case-sensitive, always considers diacritical marks, and is not affected by Considering or Ignoring statements.

ERRORS
Error
number
Error message
-50Parameter error.
-108Out of memory.
-1700Can't make some data into the expected type.
-1701Some parameter is missing for <commandName>.
-1704Some parameter was invalid.
-1705Operation involving a list item failed.
-1708<reference> doesn't understand the <commandName> message.
-1718Reply has not yet arrived.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
18 DEC 1996